package com.sxbbc.common.core.enums;

import com.sxbbc.common.basics.utils.calculation.CalcuUtils;
import com.sxbbc.common.basics.utils.statics.StaticUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 图标/banner/广告图 枚举
 * type
 * |- 1 图标
 * |- 2 banner图
 * |- 3 广告图
 * |- 4 分类
 * position
 * |- 1 app
 * |- 2 小程序
 * |- 3 wx
 * |- 4 pc
 * `position`与`type`的值 {@link StaticUtils}
 *
 * @author leehao
 * @date 2019-05-14 10:20
 */
public enum IconEnums {
    APP_ICON(1, "/icon/icon/app", "App图标管理", true, 1, 1),
    PROGRAM_ICON(2, "/icon/icon/program", "小程序图标管理", false, 2, 1),
    WX_ICON(3, "/icon/icon/wx", "微信图标管理", false, 3, 1),
    PC_ICON(4, "/icon/icon/pc", "PC图标管理", false, 4, 1),
    APP_BANNER(5, "/icon/banner/app", "AppBanner图管理", true, 1, 2),
    PROGRAM_BANNER(6, "/icon/banner/program", "小程序Banner图管理", false, 2, 2),
    WX_BANNER(7, "/icon/banner/wx", "微信Banner图管理", false, 3, 2),
    PC_BANNER(8, "/icon/banner/pc", "PCBanner图管理", false, 4, 2),
    APP_ADVERT(9, "/icon/advert/app", "App广告图管理", false, 1, 3),
    PROGRAM_ADVERT(10, "/icon/advert/program", "小程序广告图管理", false, 2, 3),
    WX_ADVERT(11, "/icon/advert/wx", "微信广告图管理", false, 3, 3),
    PC_ADVERT(12, "/icon/advert/pc", "PC广告图管理", false, 4, 3),
    APP_CLASSIFICATION(13, "/icon/advert/pc", "APP分类管理", true, 1, 4),
    PROGRAM_CLASSIFICATION(14, "/icon/advert/pc", "小程序分类图管理", false, 2, 4),
    WX_CLASSIFICATION(15, "/icon/advert/pc", "微信分类图管理", false, 3, 4),
    PC_CLASSIFICATION(16, "/icon/advert/pc", "PC分类图管理", false, 4, 4);

    private Integer id;
    private String url;
    private String name;
    private boolean show;
    private Integer position;
    private Integer type;

    IconEnums(Integer id, String url, String name, boolean show, Integer position, Integer type) {
        this.id = id;
        this.url = url;
        this.name = name;
        this.show = show;
        this.position = position;
        this.type = type;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isShow() {
        return show;
    }

    public void setShow(boolean show) {
        this.show = show;
    }

    public Integer getPosition() {
        return position;
    }

    public void setPosition(Integer position) {
        this.position = position;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    /**
     * 获取设置为'显示'的list
     */
    public static List<IconEnums> queryShowList() {
        List<IconEnums> list = new ArrayList<IconEnums>();
        for (IconEnums o : IconEnums.values()) {
            if (o.isShow()) {
                list.add(o);
            }
        }
        return list;
    }

    /**
     * 根据位置获取设置为'显示'的list
     *
     * @param type 类型 见类注释
     */
    public static List<IconEnums> queryListByType(Integer type) {
        List<IconEnums> list = new ArrayList<IconEnums>();
        for (IconEnums o : IconEnums.values()) {
            if (CalcuUtils.getInstance().isEquals(o.getType(), type) && o.isShow()) {
                list.add(o);
            }
        }
        return list;
    }

    public static String getName(Integer id) {
        String str = "";
        for (IconEnums o : IconEnums.values()) {
            if (CalcuUtils.getInstance().isEquals(id, o.getId())) {
                str = o.getName();
                break;
            }
        }
        return str;
    }
}
